package com.itsu.service.Impl;

import com.alibaba.druid.support.json.JSONUtils;
import com.itsu.dao.UserDao;
import com.itsu.domain.User;
import com.itsu.service.UserService;
import com.itsu.threadPool.MyThreadPool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import redis.clients.jedis.JedisPool;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Autowired
    private JedisPool jedisPool;

    @Override
    public User findById(Integer id) {
        User user = userDao.findById(id);
        return user;
    }

    @Override
    public void outMoney(String name, String money) {
        userDao.outMoney(name, money);
    }

    @Override
    public void printLog(String log) {
        int i = 1/0;
        userDao.printLog(log);
    }

    @Override
    public void test() {
        outMoney("joke","100");
//        printLog("取钱了");


        String json = JSONUtils.toJSONString("取钱啊");
        jedisPool.getResource().publish("print", json);
    }
}
